package cn.yunwei.module.service;

import cn.yunwei.module.controller.admin.user.vo.UserCreateReqVO;
import cn.yunwei.module.dal.dataobject.user.SystemUser;
import cn.yunwei.module.dal.mysql.user.UserMapper;
import cn.yunwei.module.util.object.BeanUtils;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;


/**
 * @author wangbinggui
 */
@Service
public class UserServiceImpl implements UserService {

   @Resource
    private UserMapper userMapper;

    @Override
    public Long addUsers(UserCreateReqVO userCreateReqVO) {
        // 将UserCreateReqVO转换为User对象
        SystemUser user = BeanUtils.toBean(userCreateReqVO, SystemUser.class);
        // 保存到数据库
        userMapper.insert(user);
        // 返回用户ID
        return user.getId();
    }

    @Override
    public SystemUser queryUser(Long id) {
        return userMapper.selectById(id);
    }
}
